package com.yyfax.common.form;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by fuqiang on 2017/5/4.
 * 根据配置的type，来决定是哪一种View
 * Copyright  2017 www.yylending.com. All Rights Reserved.
 */
public class ClassTypeSingleton {
    public  Map<Integer, String> classNames;

    private volatile static ClassTypeSingleton instance; //声明成 volatile

    private ClassTypeSingleton() {
        classNames = new HashMap<>();
        classNames.put(FormType.TYPE_NORMAL, ClearEditText.class.getName());
        classNames.put(FormType.TYPE_PHONE, ClearEditText.class.getName());
        classNames.put(FormType.TYPE_AMOUNT, ClearEditText.class.getName());
        classNames.put(FormType.TYPE_SELECT, FormSelectView.class.getName());
        classNames.put(FormType.TYPE_LOCATION, FormSelectView.class.getName());
        classNames.put(FormType.TYPE_BANKCARD, FormInputView.class.getName());
        classNames.put(FormType.TYPE_ID_CARD, FormInputView.class.getName());
        classNames.put(FormType.TYPE_COMPANY_PHONE, FormLandLineView.class.getName());
        classNames.put(FormType.TYPE_NORMAL_WITH_RIGHT_BTN, FormInputView.class.getName());
    }

    public static ClassTypeSingleton getSingleton() {
        if (instance == null) {
            synchronized (ClassTypeSingleton.class) {
                if (instance == null) {
                    instance = new ClassTypeSingleton();
                }
            }
        }
        return instance;
    }

    public Map<Integer, String> getClassNames(){
        return classNames;
    }
}
